/* root namespace **/
PWF = {
	version: '0.1',
	defaultHtmlTemplate: 'template.html',
	defaultCssTemplate: 'template.css'
};

/* namespace for mixins  */
PWF.mixin = {};

//disable log methods for now
var Log = {
  toggle: function() {},
  move: function() {},
  resize: function() {},
  clear: function() {},
  debug: function() {},
  info: function() {},
  warn: function() {},
  error: function() {},
  profile: function() {}
};


PWF.enableLogging = function() 
{
	var ScriptPath = Class.create(PWF.mixin.ScriptPath);
	var scriptPath = new ScriptPath();
	var path = scriptPath.getScriptPath('pwf-'+PWF.version);
	
	PWF.mixin.DOMUtils.loadStyleSheet(path+'logging/blackbird.css');
	PWF.mixin.DOMUtils.loadJavaScript(path+'logging/blackbird.js');
};


/* define the create function for new widgets */
PWF.create = function() 
{
	var name = arguments[0];
    if(!Object.isString(name)) {
		throw 'No class name was supplied!';
    }
    
    //build argument string for create class
    var strArgs = '';
	for(var i=1; i<arguments.length; i++)
	{
		if(i>1) {
			strArgs += ',';
		}
		strArgs += 'arguments['+i+']';
    }

    //create class using Prototype Class
	var theClass = eval('Class.create('+strArgs+');');

	//add getName() function to this class
	theClass.addMethods({
		getName: function() {
			return name;
		}
	});

    //store class instance in variable scope using the class name as variable name
	eval(name+"=theClass");
};

/** Default login handler - called on session timeout when running a widget action
  *	Override this funtion to revalidate your session using your own login implementation.
  * Call successCallback() after successful login to re-run last action automatically
  */ 
PWF.loginHandler = function(/*function ptr*/successCallback)
{
	//Call successCallback() after successful login to re-run last action automatically
};

//will be true if loginHandler is running but successCallback has not yet been called
PWF.loginHandlerInProgress = false;